﻿@model TopMenuModel
@using System.Text.RegularExpressions
@using Nop.Web.Models.Catalog;
@{
    var isRtl = this.ShouldUseRtlTheme();
}

@helper RenderSubCategoryLine(CategorySimpleModel category, int level)
{
    <li class="dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
            @category.Name
        &nbsp;<i class="fa fa-angle-down"></i>
    </a>
    <ul class="dropdown-menu sub-menu">
        @foreach (var subCategory in category.SubCategories)
        {
            @RenderCategoryLine(subCategory, level + 1)
        }
    </ul>

</li>
}

@helper RenderCategoryLine(CategorySimpleModel category, int level)
{
    if (category.SubCategories.Count > 0)
    {
        @RenderSubCategoryLine(category, 0)
    }
    else
    {
        <li>
            <a href="@Url.RouteUrl("Category", new { SeName = category.SeName })">
                @category.Name


        </a>
    </li>
    }
}

<div class="header-bottom">
    <!--header-bottom-->
    <div class="container">
        <div class="row">
            <div class="col-sm-10">
                <nav role="navigation" class="navbar">
                    <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">
                        <button data-target="#bs-example-navbar-collapse-1" data-toggle="collapse" class="navbar-toggle" type="button">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>

                    </div>

                    <!-- Collect the nav links, forms, and other content for toggling -->
                    <div id="bs-example-navbar-collapse-1" class="collapse navbar-collapse mainmenu pull-left">
                        <ul class="nav navbar-nav">
                            @Html.Widget("header_menu_before")
                            <li><a href="@Url.RouteUrl("HomePage")"><span class="glyphicon glyphicon-home"></span></a></li>
                            @foreach (var category in Model.Categories)
                            {
                                @RenderCategoryLine(category, 0)
                            }

                            @foreach (var topic in Model.Topics)
                            {
                                <li><a href="@Url.RouteUrl("Topic", new {SeName = topic.SeName})">@topic.Name</a></li>

                            }
                            @if (Model.Categories.Count == 0 && Model.Topics.Count == 0)
                            {
                                //no categories to display?
                                //in this cae let's diplay some default menu items
                                <li><a href="@Url.RouteUrl("HomePage")">@T("HomePage")</a></li>
                                if (Model.RecentlyAddedProductsEnabled)
                                {
                                    <li>
                                        <a href="@Url.RouteUrl("RecentlyAddedProducts")">@T("Products.NewProducts")</a>
                                    </li>
                                }
                                <li><a href="@Url.RouteUrl("ProductSearch")">@T("Search")</a> </li>
                                <li><a href="@Url.RouteUrl("CustomerInfo")">@T("Account.MyAccount")</a></li>
                                if (Model.BlogEnabled)
                                {
                                    <li><a href="@Url.RouteUrl("Blog")">@T("Blog")</a></li>
                                }
                                if (Model.ForumEnabled)
                                {
                                    <li><a href="@Url.RouteUrl("Boards")">@T("Forum.Forums")</a></li>
                                }
                                <li><a href="@Url.RouteUrl("ContactUs")">@T("ContactUs")</a></li>
                            }
                            @Html.Widget("header_menu_after")
                        </ul>
                    </div><!-- /.navbar-collapse -->
                </nav>
            </div>
            <div class="col-sm-2">
                @Html.Action("SearchBox", "Catalog")

            </div>
        </div>
    </div>
</div>
